
mc_htop_gui_include()

if (WIN32)
elseif (APPLE)
    mc_htop_darwin_include()
    set(gsl_htop_os_head_filepaths ${gsl_htop_darwin_head_filepaths})
    set(gsl_htop_os_source_filepaths ${gsl_htop_darwin_source_filepaths})
else()
    mc_htop_linux_include()
    set(gsl_htop_os_head_filepaths ${gsl_htop_linux_head_filepaths})
    set(gsl_htop_os_source_filepaths ${gsl_htop_linux_source_filepaths})
endif ()

set(gs_htop_ccxx_path ${gs_htop_path}/ccxx)

macro(mc_create_test1 sCppName)
    set(gsl_test_${sCppName}_sources
            main_${sCppName}.c
            )

    mc_merge_file_path(${gs_htop_ccxx_path} "${gsl_test_${sCppName}_sources}" gsl_test_${sCppName}_source_filepaths)

    add_executable(cxtest_htop_${sCppName}
            ${gsl_test_${sCppName}_source_filepaths}
            ${gsl_htop_gui_head_filepaths} ${gsl_htop_gui_source_filepaths}
            ${gsl_htop_header_filepaths} ${gsl_htop_source_filepaths}
            ${gsl_htop_os_head_filepaths} ${gsl_htop_os_source_filepaths}
            )

    add_dependencies(cxtest_htop_${sCppName}
            ccxx
            )

    target_link_libraries(cxtest_htop_${sCppName}
            ccxx
            )

    #
    #add_dependencies(cxtest_htop_${sCppName}
    #        htop_dyl
    #        )
    #
    #target_link_libraries(cxtest_htop_${sCppName}
    #        htop_dyl
    #        )

    #add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo" )

    #add_definitions(-D"DEBUG")

    mc_target_link_libraries(cxtest_htop_${sCppName})

    if (WIN32)
        if (MSVC)
            add_definitions(-D"_CRT_SECURE_NO_WARNINGS")
            add_definitions( "/wd4819" )
        endif ()
    elseif (APPLE)
        #otool -L /usr/local/bin/htop
        #/usr/local/bin/htop:
        #/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
        #/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1443.13.0)
        #/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
        #/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)

        find_library(IOKIT_LIBRARY IOKit)
        target_link_libraries(cxtest_htop_${sCppName}
                ${IOKIT_LIBRARY}
                ncurses
                )
    else()
        #ldd /usr/bin/htop
        #linux-vdso.so.1 =>  (0x00007fff93feb000)
        #libncursesw.so.5 => /lib/x86_64-linux-gnu/libncursesw.so.5 (0x00007faefd065000)
        #libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007faefce3c000)
        #libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faefcb33000)
        #libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faefc769000)
        #libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faefc565000)
        #/lib64/ld-linux-x86-64.so.2 (0x00007faefd4c1000)

        target_link_libraries(cxtest_htop_${sCppName}
                ncurses
                tinfo
                m
                )
    endif ()

    set_target_properties(cxtest_htop_${sCppName} PROPERTIES FOLDER 3rd/htop)
endmacro()

mc_create_test1(process_list1)
